import React from 'react';
import '@testing-library/jest-dom/extend-expect';
import { fireEvent, render, screen } from '@testing-library/react';
import Button from './Button';


test('should renders button text', () => {
  render(<Button>Text</Button>);
  const textElement = screen.getByText(/Text/i);
  expect(textElement).toBeInTheDocument();
});

test('should call onClick prop', () => {
  const onClickMock = jest.fn();
  render(<Button onClick={onClickMock}>Click me</Button>);
  const buttonElement = screen.getByText('Click me');
  fireEvent.click(buttonElement);
  expect(onClickMock).toBeCalledTimes(1);
});

test('should check attribute', () => {
  render(<Button disabled data-testid="button" />);
  expect(screen.getByTestId('button')).toHaveAttribute('disabled');
});
